package lxs.tool.liberator.work.controller;

import lxs.tool.liberator.common.base.result.Response;
import lxs.tool.liberator.work.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;


@RestController
@RequestMapping("work/class")
public class ClassController {
    @Autowired
    private ClassService classService;

    @GetMapping("showTable")
    public Response showTable() throws Exception {
        return classService.showTable();
    }

    @GetMapping("download")
    public Response download(String id, HttpServletResponse response) throws Exception {
        return classService.download(response, id);
    }

    @GetMapping("getOptions")
    public Response getOptions() throws Exception {
        return classService.getOptions();
    }

    @GetMapping("getMeta")
    public Response getMeta() throws Exception {
        return classService.getMeta();
    }

    @GetMapping("updateJavaName")
    public Response updateJavaName(String name, String id) {
        return classService.updateJavaName(name, id);
    }

    @GetMapping("updateIdColumn")
    public Response updateIdColumn(String idColumn, String id) {
        return classService.updateIdColumn(idColumn, id);
    }

    @GetMapping("clear")
    public Response clear(String className) throws Exception {
        return classService.clear(className);
    }

    @GetMapping("updateCount")
    public Response updateCount(String id) throws Exception {
        return classService.updateCount(id);
    }

    @GetMapping("buildData")
    public Response buildData(String id, Integer count) throws Exception {
        return classService.buildData(id, count);
    }
}
